<template>
	<view class="apps">
		<view class="mt20 plr20" v-if="list.length > 0">
			<view class="flex fdc ptb20 plr20 mb20 bgwhite" v-for="(item,index) in list" :key="index">
				<view class="flex ptb10 aic">
					<view class="f1 flex f13">{{item.out_trade_no}}</view>
					<view>
						<text class="f13" v-if="item.state == 1 && item.type == 0">已付款</text>
						<text class="f13" v-if="item.state == 1 && item.type == 1">已预约</text>
						<text class="f13" v-if="item.state == 2">待核销</text>
						<text class="f13" v-if="item.state == 3">已完成</text>
					</view>
				</view>
				<uv-line></uv-line>
				<view class="flex ptb20 aic jcsb">
					<view class="fl flex f13 c999">订单类型</view>
					<view class="f14 c666">
						<text v-if="item.type == '1'">预约单</text>
						<text v-else>支付单</text>
					</view>
				</view>
				<view class="flex ptb20 aic jcsb">
					<view class="fl flex f13 c999">商品类型</view>
					<view class="f14 c666">
						<text v-if="item.out_trade_type == 1">成人入场券</text>
						<text v-if="item.out_trade_type == 2">青少年入场券</text>
						<text v-if="item.out_trade_type == 3">至尊会员月卡</text>
						<text v-if="item.out_trade_type == 4">至尊会员季卡</text>
						<text v-if="item.out_trade_type == 5">至尊会员年卡</text>
						<text v-if="item.out_trade_type == 6">场馆预约</text>
					</view>
				</view>
				<view class="flex ptb20 aic jcsb" v-if="item.type == 0">
					<view class="fl flex f13 c999">订单金额</view>
					<view class="f14 c666">
						<text>{{item.order_amount}}</text>
					</view>
				</view>
				<uv-line></uv-line>
				<view class="flex ptb10 aic jcr">
					<uv-button plain size="small" @click="handle('/pages/order/order?id='+item.id)">详情</uv-button>
				</view>
			</view>
		</view>
		<view class="nolist" v-else>
			<uv-empty mode="list" text="无订单数据"></uv-empty>
		</view>
	</view>
</template>
<script>
	import { util } from '/common/util.js';
	let app;
	export default {
	  data() {
		return {
		  list:[],
		  page:1,
		  more:true,
		}
	  },
	  onLoad() {
		app = this;
		this.getList();
	  },
	  onReachBottom(){
	  	if(this.more == false){
	  		return false;
	  	}
	  	this.getList();
	  },
	  methods: {
		async getList(){
		 const data = await util.request({
				url:'/order/index',
				data:{page:app.page},
			});
			if(data.code == '200'){
				if(this.page == 1){
					this.list = data.data;
				}else{
					this.list.push(data.data);
				}
				this.more = data.data.length < 10 ? false : true;
				this.page+=1;
			}
		},
		handle(e){
			uni.navigateTo({
				url:e,
			})
		}
	  }
	}
</script>


<style scoped>
</style>